package com.apes.scm.masterdata.party.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：人员证件
 * @author HuJianlin
 * @create 2018-04-25 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PartyCertificate.CONST_TABLE_NAME)
public class PartyCertificate {
    public static final String CONST_TABLE_NAME = "mas_person_certificate";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "人员证件")
    private long id;   //证件编码（内码）

    @ManyToOne(optional = false)
    @JoinColumn(name = "PARTY_ID", referencedColumnName = "ID")
    private Party party; //当事人

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "certificate_type", referencedColumnName = "id")
    private Enumeration certificateType; //证件类型

    @Column(name = "certificate_number", length = 32)
    private String certificateNumber ;  //证件号码

    @Column(name = "photo_front", length = 256)
    private String photoFront;  //正面照片地址

    @Column(name = "photo_back", length = 256)
    private String photoBack;  //反面照片地址

    @Column(name = "photo_attached1", length = 256)
    private String photoAttached1;  //附页照片地址1

    @Column(name = "photo_attached2", length = 256)
    private String photoAttached2;  //附页照片地址2

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    private boolean valid = true; //有效

}
